<!--
	作者：2575202388@qq.com
	时间：2018-10-16
	描述：导航属性组件
-->
<template>
	<li :class="{active:active,li:li}" @click="activeclick">
		<slot></slot>
		<Icon v-show="iconshow" :class="iconclass" type="md-arrow-dropdown" />
	</li>
</template>

<script>
	export default {
		name: "Navigationitem",
		props: {
			active: {
				type: Boolean,
				default: function() {
					return false;
				}
			},
			iconshow: {
				type: Boolean,
				default: function() {
					return false;
				}
			},
			router: {
				type: Boolean,
				default: function() {
					return false;
				}
			}
		},
		data() {
			return {
				li: true,
				iconclass: "rotateicon1"

			}
		},
		methods: {
			activeclick() {
				this.oprationDom();
				this.iconclass = this.iconclass == "rotateicon" ? "rotateicon1" : "rotateicon";
				this.$emit("nav-click");
			},
			oprationDom() {
				let le = event.currentTarget;
				var els = le.parentNode.children;
				for(let i = 0; i < els.length; i++) {
					var ce = this.getElement(els[i]);
					if(ce) {
						ce.className = "router-link-exact-active active";
					}
					els[i].className = "li";
				}
				if(!this.router) {
					le.className = "li active";
				}
			},
			getElement(pel) {
				return pel.querySelector(".router-link-exact-active");
			}
		}
	}
</script>

<style scoped="scoped">
	.li {
		float: left;
		margin-left: 20px;
		height: 35px;
		margin-top: 5px;
		line-height: 30px;
		min-width: 80px;
		text-align: center;
		background: #f9fafe;
		color: #000000;
		cursor: pointer;
	}
	
	.li a {
		color: #000000;
		background: #f9fafe;
		min-width: 80px;
		height: 35px;
		display: block;
		padding: 0 10px;
	}
	
	.active {
		border: 1px #dcdedd solid;
		background: #FFFFFF !important;
		font-weight: bold;
	}
	
	.rotateicon {
		animation: ani-demo-spin .2s linear 1;
		transform: rotate(-180deg);
	}
	
	.rotateicon1 {
		animation: ani-demo-spin1 .2s linear 1;
		transform: rotate(0deg);
	}
	
	@keyframes ani-demo-spin1 {
		from {
			transform: rotate(-180deg);
		}
		50% {
			transform: rotate(-90deg);
		}
		to {
			transform: rotate(0deg);
		}
	}
	
	@keyframes ani-demo-spin {
		from {
			transform: rotate(0deg);
		}
		50% {
			transform: rotate(-90deg);
		}
		to {
			transform: rotate(-180deg);
		}
	}
</style>